/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainWindow.java
 *
 * Created on Mar 15, 2011, 1:49:25 PM
 */

package velib.view;

import java.awt.event.ActionListener;
import javax.swing.JButton;

/**
 *
 * @author andre
 */
public class MainWindowFrame extends javax.swing.JFrame implements IView
{

    /** Creates new form MainWindow */
    public MainWindowFrame() {
        initComponents();
        
        setUpMainWindow();
    }

    /*
     * Set up the first screen which is the WelcomeScreen
     * TODO: shouldn't some of this handled in the controller?
     */
    private void setUpMainWindow()
    {
    }


    // TODO: see CardLayout
    // See http://stackoverflow.com/questions/218155/how-do-i-change-jpanel-inside-a-jframe-on-the-fly
    //
    /*
     * Replaces the current content panel by the given one
     */
    public void setContentPanel(javax.swing.JPanel panel)
    {
        System.out.println("setContentPanel called");

        // panel.setVisible(true);
        
        middleContentPanel.removeAll();
        middleContentPanel.add(panel);
        middleContentPanel.setVisible(true);

        middleContentPanel.revalidate();
    }


    public void addEditDatabaseButtonListener(ActionListener al)
    {
        editDatabaseMenuItem.addActionListener(al);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        middleContentPanel = new javax.swing.JPanel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();
        editDatabaseMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        middleContentPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Content"));

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");

        editDatabaseMenuItem.setText("Edit DB");
        jMenu2.add(editDatabaseMenuItem);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(middleContentPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 530, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(middleContentPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 357, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainWindowFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem editDatabaseMenuItem;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel middleContentPanel;
    // End of variables declaration//GEN-END:variables

}
